package org.hgvc.webapp.ets.jsf.beans.agent;

import org.hgvc.webapp.ets.bo.Agent;
import org.hgvc.webapp.ets.spring.service.AgentService;
import org.jocsb.base.AbstractBean;
import org.jocsb.base.exception.BaseException;
import org.jocsb.base.util.FacesUtils;



public class AgentBean extends AbstractBean {
	public static final String BEAN_NAME="agentBean";
	private AgentService service;
	private Agent agent;
	public static final String NAV_PORTAL="agentPortal";
	
	public Agent getAgent() {
		return agent;
	}
	public void setAgent(Agent agent) {
		this.agent = agent;
	}
	public void setService(AgentService service) {
		this.service = service;
	}
	public void setInit(String init){};
	/*------------------------------------------------------------*/
	public String getInit(){
		try{
			if(agent==null)
				agent = service.getAgentByUserId(this.getThisUser().getUserId());
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return null;
	}
	
	public String navViewProfile(){
		AgentProfileBean bean = (AgentProfileBean)FacesUtils.getManagedBean(AgentProfileBean.BEAN_NAME);
		return bean.navViewAction(agent);
	}
	
	public String navPortalAction(){
		return NAV_PORTAL;
	}
}
